package org.sz;

import java.io.Serializable;

/**
 * Redis连接配置类
 */
public class RedisResource implements Serializable {

    private final String host;
    private final int port;
    private final String password;
    private final String keyPattern; // 用于匹配要读取的键
    
    // 连接池配置
    private int maxConnections = 8;
    private int maxIdle = 8;
    private int minIdle = 0;
    private int connectionTimeout = 2000; // 毫秒

    public RedisResource(String host, int port, String password, String keyPattern) {
        this.host = host;
        this.port = port;
        this.password = password;
        this.keyPattern = keyPattern;
    }

    public RedisResource(String host, int port, String keyPattern) {
        this(host, port, null, keyPattern);
    }

    // Getters
    public String getHost() { return host; }
    public int getPort() { return port; }
    public String getPassword() { return password; }
    public String getKeyPattern() { return keyPattern; }
    public int getMaxConnections() { return maxConnections; }
    public int getMaxIdle() { return maxIdle; }
    public int getMinIdle() { return minIdle; }
    public int getConnectionTimeout() { return connectionTimeout; }

    // Setters
    public void setMaxConnections(int maxConnections) { this.maxConnections = maxConnections; }
    public void setMaxIdle(int maxIdle) { this.maxIdle = maxIdle; }
    public void setMinIdle(int minIdle) { this.minIdle = minIdle; }
    public void setConnectionTimeout(int connectionTimeout) { this.connectionTimeout = connectionTimeout; }
}